﻿using MetroNextTools.NBase;
using MetroNextTools.NPanel;
using Windows.UI.Xaml.Controls;

namespace MetroNextTools.NControls
{
    public class NItemsPresenter : Control, IItemsPresenter
    {
        #region Fields
        private Grid _containerGrid;
        private NCollectionPanel _container;
        #endregion

        #region Constructor

        public NItemsPresenter()
        {
            this.DefaultStyleKey = typeof(NItemsPresenter);
        }

        #endregion

        #region ApplyTemplate
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _containerGrid = (Grid)base.GetTemplateChild("PART_Grid");
            _container = (NCollectionPanel)base.GetTemplateChild("PART_Container");
        }
        #endregion
     

        #region Method

        public NCollectionPanel ItemsPanel
        {
            get
            {
                if (_container == null)
                {
                    this.ApplyTemplate();
                }
                return _container;
            }
        }

        public Panel ItemsPanelHost
        {
            get
            {
                return _containerGrid;
            }
        }
        #endregion

    }
}
